import java.sql.ClientInfoStatus;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-27
 * Time: 16:30
 */
public class Test {
    public static void main(String[] args) {
        List<List<Integer>> list = new ArrayList<>();
        List<Integer> list1 = new ArrayList<>();
        list1.add(1);
        list1.add(2);
        list.add(list1);
        List<Integer> list2 = new ArrayList<>();
        list2.add(3);
        list2.add(4);
        list.add(list2);
        System.out.println(list);

    }
    public static void main3(String[] args) {
        String str1 = "welcome to ujb";
        String str2 = "come";
        ArrayList<Character> list = new ArrayList<>();

        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            if(!str2.contains(ch + "")){
                list.add(ch);
            }
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i));
        }
    }
    public static void main2(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        System.out.println(list);
        //迭代器从后往前打印
        ListIterator<Integer> it3 = list.listIterator(list.size());
        while(it3.hasPrevious()){
            System.out.print(it3.previous() + " ");
        }
        System.out.println();
        //迭代器
        Iterator<Integer> it = list.iterator();
        while(it.hasNext()){
            System.out.print(it.next() + " ");
        }

        System.out.println();
        //迭代器
        ListIterator<Integer> it2 = list.listIterator();
        while (it2.hasNext()){
            System.out.print(it2.next() + " ");
        }
        System.out.println();
        int sz = list.size();
        //for循环
        for (int i = 0; i < sz; i++) {
            System.out.print(list.get(i) + " ");
        }
        System.out.println();
        //foreach循环
       for( Integer x: list){
           System.out.print(x + " ");
       }
    }

    public static void main1(String[] args) {
        ArrayList<Integer> list = new ArrayList<>(10);
        List<Integer> list2 = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        list.add(1,2);

        list2 = list.subList(1,3);

        list2.set(0,99);

        ArrayList<Integer> test = new ArrayList<>();
        test.add(1);
        test.addAll(1,list);

        System.out.println(list2);
        System.out.println(test);
    }
}
